    // 创建cookie
    function setCookie(key,value,day){
        var d = new Date()
        d.setDate(d.getDate()+day)
        document.cookie = `${key}=${value};expires=${d}`
    }
    
    // setCookie('username','zhangsan','7');
    
    // 获取cookie
    function getCookie(value){
        var cookie = document.cookie;
        var arr = cookie.split('; ');
        for(var i in arr){
            var newarr = arr[i].split('=');
            if(newarr[0]==value){
                return newarr[1];
            }
        }
        return ''
    }
    
    // console.log(getCookie('username'));
// 删除
function delCookie(key){
    setCookie(key,'',-1)
}
    